<!--  -->
<template>
  <div>
    <van-nav-bar title="我的订单" left-text="返回" left-arrow />
<van-tabs v-model="active" animated>
 <van-tab title="全部">
        <van-card v-for="(item) in order" :key="item.orderId" :num="item.orderGoodsNum" :price="item.orderGoodsPrice" :desc="item.goods.goodsDesc" :title="item.goods.goodsName" :thumb="item.goods.goodsImg">
  <template #tags>
    
    <van-tag v-if="item.orderStatus==0 " plain type="danger">待付款</van-tag>
    <van-tag v-if="item.orderStatus==1 " plain type="danger">待发货</van-tag>
    <van-tag v-if="item.orderStatus==2 " plain type="danger">待收货</van-tag>
    <van-tag v-if="item.orderStatus==3 " plain type="danger">已收货</van-tag>
    <van-tag v-if="item.orderStatus==4 " plain type="danger">待评论</van-tag>
    <van-tag v-if="item.orderStatus==5 " plain type="danger">待退款</van-tag>
    <van-tag v-if="item.orderStatus==6 " plain type="danger">退款成功 </van-tag>

    


  </template>
  <template #footer>
    <van-button size="mini" v-if="item.orderStatus==0" @click="fk()">付款</van-button>
    <van-button size="mini"  v-if="item.orderStatus==3" @click="go(item.orderId,item.userId,item.goods.goodsId)">评价</van-button>
    <van-button size="mini"  v-if="item.orderStatus==4" @click="go(item.orderId,item.userId,item.goods.goodsId)">评价</van-button>
    <van-button size="mini"  v-if="item.orderStatus==1" @click="cui">申请退款</van-button>
    <van-button size="mini"  v-if="item.orderStatus==1" @click="cui">催一下</van-button>
    <van-button size="mini"  v-if="item.orderStatus==2 " @click="Receiving(item.orderId)">确定收货</van-button>

  </template>
        </van-card>
 </van-tab>
    <van-tab title="待付款">
     <van-card v-for="(item) in payment" :key="item.orderId" :num="item.orderGoodsNum" :price="item.orderGoodsPrice" :desc="item.goods.goodsDesc" :title="item.goods.goodsName" :thumb="item.goods.goodsImg">
  <template #tags>
    <van-tag plain type="danger">待付款</van-tag>
  
  </template>
  <template #footer>
    <van-button size="mini" @click="fk()">付款</van-button>
  </template>
        </van-card>
 </van-tab>

  <van-tab title="待发货">
       <van-card v-for="(item) in deliver_goods" :key="item.orderId" :num="item.orderGoodsNum" :price="item.orderGoodsPrice" :desc="item.goods.goodsDesc" :title="item.goods.goodsName" :thumb="item.goods.goodsImg">
  <template #tags>
    <van-tag plain type="danger">待发货</van-tag>
    
  </template>
  <template #footer>
    <van-button size="mini" @click="cui">申请退款</van-button>
    <van-button size="mini" @click="cui">催一下</van-button>
  </template>
        </van-card>
  </van-tab>
  <van-tab title="待收货">
    <van-card v-for="(item) in Receiving_goods" :key="item.orderId" :num="item.orderGoodsNum" :price="item.orderGoodsPrice" :desc="item.goods.goodsDesc" :title="item.goods.goodsName" :thumb="item.goods.goodsImg">
  <template #tags>
    <van-tag plain  type="danger">待收货</van-tag>

  </template>
  <template #footer>
    <van-button size="mini" @click="Receiving(item.orderId)">确定收货</van-button>
  </template>
        </van-card>
  </van-tab>
  <van-tab title="待评价">
        <van-card v-for="(item) in evaluate" :key="item.orderId" :num="item.orderGoodsNum" :price="item.orderGoodsPrice" :desc="item.goods.goodsDesc" :title="item.goods.goodsName" :thumb="item.goods.goodsImg">
  <template #tags>
    
    <van-tag plain type="danger">待评价</van-tag>
  </template>
  <template #footer>
    <van-button size="mini" @click="go(item.orderId,item.userId,item.goods.goodsId)">评价</van-button>
  </template>
        </van-card>

  </van-tab>
</van-tabs>

  </div>
</template>

<script>
export default {
name : 'share',
data(){
    return {
      //全部列表
      order:{},
      // 待评价
        evaluate:{},
       //待收货
      Receiving_goods:{},
        //待发货
      deliver_goods:{},
        // 待付款
        payment:{},
        active:'',
      
    }
},
methods:{
  go(id,userId,gid){
    this.$router.push({path:'publishcomments',query:{id:id,userId:userId,goodsId:gid}})
  },
  sh(id){
    this.$axios.post('/api/marketOrder/confirmDelivery?orderId='+id).then((res)=>{
      console.log("确认收货")
    })
  },
  cui(){
    
  },
  Receiving(id){
      this.$axios.post('/api/marketOrder/confirmDelivery?orderId='+id).then((res)=>{
          console.log(res)
    }).catch((err)=>{console.log("失败")})
  }
},
// '+sess.userId+'

created(){
    let sess = JSON.parse(sessionStorage.getItem("user"))

  //全部
  this.$axios.post('/api/marketOrder/myOrderList?userId=1').then((res)=>{
    this.order=res.data.data
    console.log(res.data.data)
  }).catch((err)=>{console.log(1)})
  //待收货
   this.$axios.post('/api/marketOrder/myOrderList?userId=1&orderStatus=2').then((res)=>{
    this.Receiving_goods=res.data.data
    // console.log(res.data.data)
  }).catch((err)=>{console.log(2)})
  //待发货
    this.$axios.post('/api/marketOrder/myOrderList?userId=1&orderStatus=1').then((res)=>{
    this.deliver_goods=res.data.data
    // console.log(res.data.data)
  }).catch((err)=>{console.log(3)})
// 待付款
  this.$axios.post('/api/marketOrder/myOrderList?userId=1&orderStatus=0').then((res)=>{
    this.payment=res.data.data
    // console.log(res.data.data)
  }).catch((err)=>{console.log(4)})
  // 待评价
   this.$axios.post('/api/marketOrder/myOrderList?userId=1&orderStatus=4').then((res)=>{
    this.evaluate=res.data.data
    // console.log(res.data.data)
  }).catch((err)=>{console.log(5)})

  // sessionStorage.setItem('uresid',JSON.stringify(this.acc))

}

  }
</script>

<style  scoped>

</style>
